package com.jason.www.state_pattern.demo1.context;


import lombok.Data;
import com.jason.www.state_pattern.demo1.state.IRoomState;
import com.jason.www.state_pattern.demo1.state.RoomBookedState;
import com.jason.www.state_pattern.demo1.state.RoomCheckInState;
import com.jason.www.state_pattern.demo1.state.RoomFreeTimeState;

/**
 * Context类：环境类，包括一些内部状态。
 * https://www.imooc.com/article/16203?block_id=tuijian_wz
 */
@Data
public class RoomContext{
    private IRoomState freeTimeState;
    private IRoomState chechInState;
    private IRoomState bookedState;

    private IRoomState state;

    public RoomContext() {
        freeTimeState = new RoomFreeTimeState(this);
        chechInState = new RoomCheckInState(this);
        bookedState = new RoomBookedState(this);
        this.state = freeTimeState;
    }

    public void bookRoom() {
        state.bookRoom();
    }

    public void unsubscribeRoom() {
        state.unsubscribeRoom();
    }

    public void checkInRoom() {
        state.checkInRoom();
    }

    public void checkOutRoom() {
        state.checkOutRoom();
    }
}
